<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>(kv-store)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">(kv-store)</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__group__kvstore.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">Key Value Storage Library</div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p >This library provides a convenient way to store information as key-value pairs in non-volatile storage. </p>
<h1><a class="anchor" id="section_kvstore_getting_started"></a>
Getting Started</h1>
<p >This section provides steps for getting started with this library by using the block storage interface.<a href="https://github.com/infineon/block-storage">block-storage</a></p>
<ol type="1">
<li>Include the kv-store library header in the application. <div class="fragment"><div class="line"><span class="preprocessor">#include &quot;mtb_kvstore.h&quot;</span></div>
</div><!-- fragment --></li>
<li>Initialize the underlying storage. This could be done using either the HAL NVM or Serial Memory depending on the storage<ul>
<li>Example initialization for hal API 3.0 nvm driver <div class="fragment"><div class="line">    mtb_hal_nvm_t nvm_obj;</div>
<div class="line">    mtb_hal_nvm_region_info_t block_info;</div>
<div class="line">    cy_rslt_t result = mtb_hal_nvm_setup(&amp;nvm_obj, NULL);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="line">    mtb_hal_nvm_info_t nvm_info;</div>
<div class="line">    mtb_hal_nvm_get_info(&amp;nvm_obj, &amp;nvm_info);</div>
<div class="line">    block_info = nvm_info.regions[nvm_info.region_count - 1];</div>
</div><!-- fragment --></li>
<li>Example initialization for serial memory driver <div class="fragment"><div class="line">    mtb_serial_memory_t serial_memory_obj;</div>
<div class="line">    cy_stc_smif_context_t context;</div>
<div class="line">    <span class="comment">/* Setup the serial memory object */</span></div>
<div class="line">    cy_rslt_t result = mtb_serial_memory_setup(</div>
<div class="line">        &amp;serial_memory_obj, MTB_SERIAL_MEMORY_CHIP_SELECT_0,</div>
<div class="line">        &amp;base_address, &amp;sm_clock, &amp;context, &amp;smif_block_obj);</div>
</div><!-- fragment --></li>
<li>Example initialization for hal API 2.0 nvm driver <div class="fragment"><div class="line">    cyhal_nvm_t nvm_obj;</div>
<div class="line">    cyhal_nvm_region_info_t block_info;</div>
<div class="line">    cy_rslt_t result = cyhal_nvm_init(&amp;nvm_obj);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="line">    cyhal_nvm_info_t nvm_info;</div>
<div class="line">    cyhal_nvm_get_info(&amp;nvm_obj, &amp;nvm_info);</div>
<div class="line">    block_info = nvm_info.regions[nvm_info.region_count - 1];</div>
</div><!-- fragment --></li>
</ul>
</li>
<li>Create the block storage interface using the HAL NVM or the serial memory.If neither the HAL NVM nor serial memory driver is being used to communicate with the storage device, the application must provide a custom implementation of the block device interface.<ul>
<li>Example implementation using block storage HAL 3.0 NVM interface <div class="fragment"><div class="line">    mtb_block_storage_t nvm_bsd;</div>
<div class="line">    mtb_block_storage_create_hal_nvm(&amp;nvm_bsd, &amp;nvm_obj);</div>
</div><!-- fragment --></li>
<li>Example implementation using block storage serial-memory interface <div class="fragment"><div class="line">    <span class="comment">/* Create the block-storage - serial memory object */</span></div>
<div class="line">    mtb_block_storage_t serial_memory_bsd;</div>
<div class="line">    mtb_block_storage_create_serial_memory(&amp;serial_memory_bsd, &amp;serial_memory_obj);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
</div><!-- fragment --></li>
<li>Example implementation using block storage HAL Classic NVM interface <div class="fragment"><div class="line">    mtb_block_storage_t nvm_bsd;</div>
<div class="line">    mtb_block_storage_nvm_create(&amp;nvm_bsd);</div>
</div><!-- fragment --></li>
</ul>
</li>
<li>Initialize the kv-store library.<ul>
<li>Set the start address and length.<ul>
<li>If using the hal-nvm driver, for this example the address space provided starts 16 pages from the end of the nvm. Note that if the device does not have a working flash (i.e. using main flash) care must be taken to ensure that the space allocated below is not used by anything else (for eg. Application image). <div class="fragment"><div class="line">    uint32_t length = 16U * block_info.block_size;</div>
<div class="line">    uint32_t start_addr = block_info.start_address + block_info.size - length;</div>
</div><!-- fragment --></li>
<li>If using the serial-memory library, for this example we define the space provided to the kv-store library to be the size of 2 sectors. <div class="fragment"><div class="line">    uint32_t start_addr = 0;</div>
<div class="line">    uint32_t sector_size = serial_memory_bsd.get_erase_size(serial_memory_bsd.context, start_addr);</div>
<div class="line">    uint32_t length = sector_size * 2;</div>
<div class="line"> </div>
</div><!-- fragment --></li>
</ul>
</li>
<li>Call <a class="el" href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a> by passing the start address, length, block device and the optional memory allocate and free function pointers <div class="fragment"><div class="line">    mtb_kvstore_t      obj;</div>
<div class="line">    result = <a class="code hl_function" href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a>(&amp;obj, start_addr, length, &amp;nvm_bsd, NULL, NULL);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="ttc" id="agroup__group__kvstore_html_ga5fa9ddeac64024562e60999088f638b7"><div class="ttname"><a href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a></div><div class="ttdeci">cy_rslt_t mtb_kvstore_init(mtb_kvstore_t *obj, uint32_t start_addr, uint32_t length, const mtb_block_storage_t *bsd, mtb_kvstore_allocate_memory_t alloc_memory, mtb_kvstore_free_memory_t free_memory)</div><div class="ttdoc">Initialize an instance of the kv-store library.</div><div class="ttdef"><b>Definition:</b> mtb_kvstore.c:1568</div></div>
</div><!-- fragment --></li>
</ul>
</li>
<li>The library should now be ready to perform operations.<ul>
<li>Write operation. <div class="fragment"><div class="line">    uint8_t data[10];</div>
<div class="line">    result = <a class="code hl_function" href="group__group__kvstore.html#ga209eef7f4603173449de48d3d4775835">mtb_kvstore_write</a>(&amp;obj, <span class="stringliteral">&quot;hello&quot;</span>, data, <span class="keyword">sizeof</span>(data));</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="ttc" id="agroup__group__kvstore_html_ga209eef7f4603173449de48d3d4775835"><div class="ttname"><a href="group__group__kvstore.html#ga209eef7f4603173449de48d3d4775835">mtb_kvstore_write</a></div><div class="ttdeci">cy_rslt_t mtb_kvstore_write(mtb_kvstore_t *obj, const char *key, const uint8_t *data, uint32_t size)</div><div class="ttdoc">Store a key value pair.</div><div class="ttdef"><b>Definition:</b> mtb_kvstore.c:1659</div></div>
</div><!-- fragment --></li>
<li>Read operation. <div class="fragment"><div class="line">    uint8_t read_data[10];</div>
<div class="line">    uint32_t data_size = <span class="keyword">sizeof</span>(read_data);</div>
<div class="line">    result = <a class="code hl_function" href="group__group__kvstore.html#gad2327026f8f741835d012aa0a1f60f14">mtb_kvstore_read</a>(&amp;obj, <span class="stringliteral">&quot;hello&quot;</span>, read_data, &amp;data_size);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="ttc" id="agroup__group__kvstore_html_gad2327026f8f741835d012aa0a1f60f14"><div class="ttname"><a href="group__group__kvstore.html#gad2327026f8f741835d012aa0a1f60f14">mtb_kvstore_read</a></div><div class="ttdeci">cy_rslt_t mtb_kvstore_read(mtb_kvstore_t *obj, const char *key, uint8_t *data, uint32_t *size)</div><div class="ttdoc">Read data associated with a key.</div><div class="ttdef"><b>Definition:</b> mtb_kvstore.c:1741</div></div>
</div><!-- fragment --></li>
<li>Delete operation. <div class="fragment"><div class="line">    result = <a class="code hl_function" href="group__group__kvstore.html#gafb22467328e29fd0b881eae93679a0f9">mtb_kvstore_delete</a>(&amp;obj, <span class="stringliteral">&quot;hello&quot;</span>);</div>
<div class="line">    CY_ASSERT(result == CY_RSLT_SUCCESS);</div>
<div class="ttc" id="agroup__group__kvstore_html_gafb22467328e29fd0b881eae93679a0f9"><div class="ttname"><a href="group__group__kvstore.html#gafb22467328e29fd0b881eae93679a0f9">mtb_kvstore_delete</a></div><div class="ttdeci">cy_rslt_t mtb_kvstore_delete(mtb_kvstore_t *obj, const char *key)</div><div class="ttdoc">Delete a key value pair.</div><div class="ttdef"><b>Definition:</b> mtb_kvstore.c:1866</div></div>
</div><!-- fragment --> </li>
</ul>
</li>
</ol>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga23dc5337825e5abb56afd1938b41e997"><td class="memItemLeft" align="right" valign="top"><a id="ga23dc5337825e5abb56afd1938b41e997" name="ga23dc5337825e5abb56afd1938b41e997"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_MAX_KEY_SIZE</b>&#160;&#160;&#160;(64U)</td></tr>
<tr class="memdesc:ga23dc5337825e5abb56afd1938b41e997"><td class="mdescLeft">&#160;</td><td class="mdescRight">Maximum key size permitted. <br /></td></tr>
<tr class="separator:ga23dc5337825e5abb56afd1938b41e997"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab15b7f2a1cea77f4621f72c8082ae352"><td class="memItemLeft" align="right" valign="top"><a id="gab15b7f2a1cea77f4621f72c8082ae352" name="gab15b7f2a1cea77f4621f72c8082ae352"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_ENSURE_MAX</b>&#160;&#160;&#160;(0xFFFFFFFFu)</td></tr>
<tr class="memdesc:gab15b7f2a1cea77f4621f72c8082ae352"><td class="mdescLeft">&#160;</td><td class="mdescRight">When passed as an argument to <a class="el" href="group__group__kvstore.html#gad0c50e719da0063d48d9d6224d22c756">mtb_kvstore_ensure_capacity</a>, indicates that cleanup tasks should always be performed regardless of the amount of space which is currently free, to ensure the maximum possible amount of free space is available. <br /></td></tr>
<tr class="separator:gab15b7f2a1cea77f4621f72c8082ae352"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf080d74c7e7cd0b04649ce6617831e74"><td class="memItemLeft" align="right" valign="top"><a id="gaf080d74c7e7cd0b04649ce6617831e74" name="gaf080d74c7e7cd0b04649ce6617831e74"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_BAD_PARAM_ERROR</b>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 0)</td></tr>
<tr class="memdesc:gaf080d74c7e7cd0b04649ce6617831e74"><td class="mdescLeft">&#160;</td><td class="mdescRight">An invalid parameter value is passed in. <br /></td></tr>
<tr class="separator:gaf080d74c7e7cd0b04649ce6617831e74"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4513227045ee358f8f2622c8cf0a3485"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga4513227045ee358f8f2622c8cf0a3485">MTB_KVSTORE_ALIGNMENT_ERROR</a>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 1)</td></tr>
<tr class="memdesc:ga4513227045ee358f8f2622c8cf0a3485"><td class="mdescLeft">&#160;</td><td class="mdescRight">The storage area passed in is not aligned to erase sector boundary.  <a href="group__group__kvstore.html#ga4513227045ee358f8f2622c8cf0a3485">More...</a><br /></td></tr>
<tr class="separator:ga4513227045ee358f8f2622c8cf0a3485"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa4476b5e7db68726ae74b0153690fbfc"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gaa4476b5e7db68726ae74b0153690fbfc">MTB_KVSTORE_MEM_ALLOC_ERROR</a>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 2)</td></tr>
<tr class="memdesc:gaa4476b5e7db68726ae74b0153690fbfc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Memory allocation failed.  <a href="group__group__kvstore.html#gaa4476b5e7db68726ae74b0153690fbfc">More...</a><br /></td></tr>
<tr class="separator:gaa4476b5e7db68726ae74b0153690fbfc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga231945421777b158f99b21e5bc2ffde0"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga231945421777b158f99b21e5bc2ffde0">MTB_KVSTORE_INVALID_DATA_ERROR</a>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 3)</td></tr>
<tr class="memdesc:ga231945421777b158f99b21e5bc2ffde0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Invalid data was detected.  <a href="group__group__kvstore.html#ga231945421777b158f99b21e5bc2ffde0">More...</a><br /></td></tr>
<tr class="separator:ga231945421777b158f99b21e5bc2ffde0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga531cd29dc9167444df1474d15a9e263f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga531cd29dc9167444df1474d15a9e263f">MTB_KVSTORE_ERASED_DATA_ERROR</a>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 4)</td></tr>
<tr class="memdesc:ga531cd29dc9167444df1474d15a9e263f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Erased data was detected.  <a href="group__group__kvstore.html#ga531cd29dc9167444df1474d15a9e263f">More...</a><br /></td></tr>
<tr class="separator:ga531cd29dc9167444df1474d15a9e263f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0b1535ec72da31cca2681a2990d69d60"><td class="memItemLeft" align="right" valign="top"><a id="ga0b1535ec72da31cca2681a2990d69d60" name="ga0b1535ec72da31cca2681a2990d69d60"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_ITEM_NOT_FOUND_ERROR</b>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 5)</td></tr>
<tr class="memdesc:ga0b1535ec72da31cca2681a2990d69d60"><td class="mdescLeft">&#160;</td><td class="mdescRight">Item was not found in the storage. <br /></td></tr>
<tr class="separator:ga0b1535ec72da31cca2681a2990d69d60"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf746e26fd8da70e4169614b530371a65"><td class="memItemLeft" align="right" valign="top"><a id="gaf746e26fd8da70e4169614b530371a65" name="gaf746e26fd8da70e4169614b530371a65"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_STORAGE_FULL_ERROR</b>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 6)</td></tr>
<tr class="memdesc:gaf746e26fd8da70e4169614b530371a65"><td class="mdescLeft">&#160;</td><td class="mdescRight">The storage is full. <br /></td></tr>
<tr class="separator:gaf746e26fd8da70e4169614b530371a65"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3b7ec8bfe496de11d5961eddf55eb8a8"><td class="memItemLeft" align="right" valign="top"><a id="ga3b7ec8bfe496de11d5961eddf55eb8a8" name="ga3b7ec8bfe496de11d5961eddf55eb8a8"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>MTB_KVSTORE_BUFFER_TOO_SMALL</b>&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 7)</td></tr>
<tr class="memdesc:ga3b7ec8bfe496de11d5961eddf55eb8a8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Buffer provided is too small for value found. <br /></td></tr>
<tr class="separator:ga3b7ec8bfe496de11d5961eddf55eb8a8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gacccba62e614b1ebb309dc312b7b67e3a"><td class="memItemLeft" align="right" valign="top">typedef cy_rslt_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gacccba62e614b1ebb309dc312b7b67e3a">mtb_kvstore_bd_read</a>) (void *context, uint32_t addr, uint32_t length, uint8_t *buf)</td></tr>
<tr class="memdesc:gacccba62e614b1ebb309dc312b7b67e3a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype for reading data from the block device.  <a href="group__group__kvstore.html#gacccba62e614b1ebb309dc312b7b67e3a">More...</a><br /></td></tr>
<tr class="separator:gacccba62e614b1ebb309dc312b7b67e3a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa832bac0e2f7b15478abb73ae8631b8d"><td class="memItemLeft" align="right" valign="top">typedef cy_rslt_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gaa832bac0e2f7b15478abb73ae8631b8d">mtb_kvstore_bd_program</a>) (void *context, uint32_t addr, uint32_t length, const uint8_t *buf)</td></tr>
<tr class="memdesc:gaa832bac0e2f7b15478abb73ae8631b8d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype for writing data to the block device.  <a href="group__group__kvstore.html#gaa832bac0e2f7b15478abb73ae8631b8d">More...</a><br /></td></tr>
<tr class="separator:gaa832bac0e2f7b15478abb73ae8631b8d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8eee071bb3809130b77fb7c8f69e7a67"><td class="memItemLeft" align="right" valign="top">typedef cy_rslt_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga8eee071bb3809130b77fb7c8f69e7a67">mtb_kvstore_bd_erase</a>) (void *context, uint32_t addr, uint32_t length)</td></tr>
<tr class="memdesc:ga8eee071bb3809130b77fb7c8f69e7a67"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype for read from the block device.  <a href="group__group__kvstore.html#ga8eee071bb3809130b77fb7c8f69e7a67">More...</a><br /></td></tr>
<tr class="separator:ga8eee071bb3809130b77fb7c8f69e7a67"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4d03d5b99d6254298f9eaefb0978170f"><td class="memItemLeft" align="right" valign="top">typedef uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga4d03d5b99d6254298f9eaefb0978170f">mtb_kvstore_bd_read_size</a>) (void *context, uint32_t addr)</td></tr>
<tr class="memdesc:ga4d03d5b99d6254298f9eaefb0978170f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype to get the read size of the block device for a specific address.  <a href="group__group__kvstore.html#ga4d03d5b99d6254298f9eaefb0978170f">More...</a><br /></td></tr>
<tr class="separator:ga4d03d5b99d6254298f9eaefb0978170f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga33782352587721d63e4ca26f35558d90"><td class="memItemLeft" align="right" valign="top">typedef uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga33782352587721d63e4ca26f35558d90">mtb_kvstore_bd_program_size</a>) (void *context, uint32_t addr)</td></tr>
<tr class="memdesc:ga33782352587721d63e4ca26f35558d90"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype to get the program size of the block device for a specific address.  <a href="group__group__kvstore.html#ga33782352587721d63e4ca26f35558d90">More...</a><br /></td></tr>
<tr class="separator:ga33782352587721d63e4ca26f35558d90"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9dcd451cefcdae7d7063aa2e173b948b"><td class="memItemLeft" align="right" valign="top">typedef uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga9dcd451cefcdae7d7063aa2e173b948b">mtb_kvstore_bd_erase_size</a>) (void *context, uint32_t addr)</td></tr>
<tr class="memdesc:ga9dcd451cefcdae7d7063aa2e173b948b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype to get the erase size of the block device for a specific address.  <a href="group__group__kvstore.html#ga9dcd451cefcdae7d7063aa2e173b948b">More...</a><br /></td></tr>
<tr class="separator:ga9dcd451cefcdae7d7063aa2e173b948b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf4640989209ce778da48555edeb7f531"><td class="memItemLeft" align="right" valign="top">typedef void *(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gaf4640989209ce778da48555edeb7f531">mtb_kvstore_allocate_memory_t</a>) (size_t size)</td></tr>
<tr class="memdesc:gaf4640989209ce778da48555edeb7f531"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype for allocating memory to be used for kv-store internal operations.  <a href="group__group__kvstore.html#gaf4640989209ce778da48555edeb7f531">More...</a><br /></td></tr>
<tr class="separator:gaf4640989209ce778da48555edeb7f531"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacc6ed573c4d9f8c441bd4605d26ddd81"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gacc6ed573c4d9f8c441bd4605d26ddd81">mtb_kvstore_free_memory_t</a>) (void *ptr)</td></tr>
<tr class="memdesc:gacc6ed573c4d9f8c441bd4605d26ddd81"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function prototype for freeing memory.  <a href="group__group__kvstore.html#gacc6ed573c4d9f8c441bd4605d26ddd81">More...</a><br /></td></tr>
<tr class="separator:gacc6ed573c4d9f8c441bd4605d26ddd81"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga5fa9ddeac64024562e60999088f638b7"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a> (mtb_kvstore_t *obj, uint32_t start_addr, uint32_t length, const mtb_block_storage_t *bsd, <a class="el" href="group__group__kvstore.html#gaf4640989209ce778da48555edeb7f531">mtb_kvstore_allocate_memory_t</a> alloc_memory, <a class="el" href="group__group__kvstore.html#gacc6ed573c4d9f8c441bd4605d26ddd81">mtb_kvstore_free_memory_t</a> free_memory)</td></tr>
<tr class="memdesc:ga5fa9ddeac64024562e60999088f638b7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize an instance of the kv-store library.  <a href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">More...</a><br /></td></tr>
<tr class="separator:ga5fa9ddeac64024562e60999088f638b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga209eef7f4603173449de48d3d4775835"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga209eef7f4603173449de48d3d4775835">mtb_kvstore_write</a> (mtb_kvstore_t *obj, const char *key, const uint8_t *data, uint32_t size)</td></tr>
<tr class="memdesc:ga209eef7f4603173449de48d3d4775835"><td class="mdescLeft">&#160;</td><td class="mdescRight">Store a key value pair.  <a href="group__group__kvstore.html#ga209eef7f4603173449de48d3d4775835">More...</a><br /></td></tr>
<tr class="separator:ga209eef7f4603173449de48d3d4775835"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad2327026f8f741835d012aa0a1f60f14"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gad2327026f8f741835d012aa0a1f60f14">mtb_kvstore_read</a> (mtb_kvstore_t *obj, const char *key, uint8_t *data, uint32_t *size)</td></tr>
<tr class="memdesc:gad2327026f8f741835d012aa0a1f60f14"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read data associated with a key.  <a href="group__group__kvstore.html#gad2327026f8f741835d012aa0a1f60f14">More...</a><br /></td></tr>
<tr class="separator:gad2327026f8f741835d012aa0a1f60f14"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadd5125b0adf2ef5a4afc39851aeaa288"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gadd5125b0adf2ef5a4afc39851aeaa288">mtb_kvstore_read_partial</a> (mtb_kvstore_t *obj, const char *key, uint8_t *data, uint32_t *size, const uint32_t offset_bytes)</td></tr>
<tr class="memdesc:gadd5125b0adf2ef5a4afc39851aeaa288"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read data associated with a key.  <a href="group__group__kvstore.html#gadd5125b0adf2ef5a4afc39851aeaa288">More...</a><br /></td></tr>
<tr class="separator:gadd5125b0adf2ef5a4afc39851aeaa288"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga16b0bc2c58f9a4259d295746df43c8ad"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga16b0bc2c58f9a4259d295746df43c8ad">mtb_kvstore_key_exists</a> (mtb_kvstore_t *obj, const char *key)</td></tr>
<tr class="memdesc:ga16b0bc2c58f9a4259d295746df43c8ad"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check if a key is stored in memory.  <a href="group__group__kvstore.html#ga16b0bc2c58f9a4259d295746df43c8ad">More...</a><br /></td></tr>
<tr class="separator:ga16b0bc2c58f9a4259d295746df43c8ad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafd3c856a28b4a326f6e2982f0d18b6dc"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gafd3c856a28b4a326f6e2982f0d18b6dc">mtb_kvstore_value_size</a> (mtb_kvstore_t *obj, const char *key, uint32_t *size)</td></tr>
<tr class="memdesc:gafd3c856a28b4a326f6e2982f0d18b6dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the size in bytes of data in memory corresponding to a given key.  <a href="group__group__kvstore.html#gafd3c856a28b4a326f6e2982f0d18b6dc">More...</a><br /></td></tr>
<tr class="separator:gafd3c856a28b4a326f6e2982f0d18b6dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafb22467328e29fd0b881eae93679a0f9"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gafb22467328e29fd0b881eae93679a0f9">mtb_kvstore_delete</a> (mtb_kvstore_t *obj, const char *key)</td></tr>
<tr class="memdesc:gafb22467328e29fd0b881eae93679a0f9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete a key value pair.  <a href="group__group__kvstore.html#gafb22467328e29fd0b881eae93679a0f9">More...</a><br /></td></tr>
<tr class="separator:gafb22467328e29fd0b881eae93679a0f9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga543e217c6dad81778e1fc9926e28f23f"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga543e217c6dad81778e1fc9926e28f23f">mtb_kvstore_size</a> (mtb_kvstore_t *obj)</td></tr>
<tr class="memdesc:ga543e217c6dad81778e1fc9926e28f23f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Query the size consumed in the kv-store storage.  <a href="group__group__kvstore.html#ga543e217c6dad81778e1fc9926e28f23f">More...</a><br /></td></tr>
<tr class="separator:ga543e217c6dad81778e1fc9926e28f23f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga51591921642d49be5e5c8a9814bebd39"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga51591921642d49be5e5c8a9814bebd39">mtb_kvstore_remaining_size</a> (mtb_kvstore_t *obj)</td></tr>
<tr class="memdesc:ga51591921642d49be5e5c8a9814bebd39"><td class="mdescLeft">&#160;</td><td class="mdescRight">Query the free space available in the kv-store storage.  <a href="group__group__kvstore.html#ga51591921642d49be5e5c8a9814bebd39">More...</a><br /></td></tr>
<tr class="separator:ga51591921642d49be5e5c8a9814bebd39"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad0c50e719da0063d48d9d6224d22c756"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#gad0c50e719da0063d48d9d6224d22c756">mtb_kvstore_ensure_capacity</a> (mtb_kvstore_t *obj, uint32_t size)</td></tr>
<tr class="memdesc:gad0c50e719da0063d48d9d6224d22c756"><td class="mdescLeft">&#160;</td><td class="mdescRight">Tries to make the specified amount of space available for immediate use.  <a href="group__group__kvstore.html#gad0c50e719da0063d48d9d6224d22c756">More...</a><br /></td></tr>
<tr class="separator:gad0c50e719da0063d48d9d6224d22c756"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5dc849717a6e3c8b7803fe2224cc6df1"><td class="memItemLeft" align="right" valign="top">cy_rslt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga5dc849717a6e3c8b7803fe2224cc6df1">mtb_kvstore_reset</a> (mtb_kvstore_t *obj)</td></tr>
<tr class="memdesc:ga5dc849717a6e3c8b7803fe2224cc6df1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reset kv-store storage.  <a href="group__group__kvstore.html#ga5dc849717a6e3c8b7803fe2224cc6df1">More...</a><br /></td></tr>
<tr class="separator:ga5dc849717a6e3c8b7803fe2224cc6df1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4388f0dd869ef9dbe2da0d2920cca290"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__kvstore.html#ga4388f0dd869ef9dbe2da0d2920cca290">mtb_kvstore_deinit</a> (mtb_kvstore_t *obj)</td></tr>
<tr class="memdesc:ga4388f0dd869ef9dbe2da0d2920cca290"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete kv-store instance.  <a href="group__group__kvstore.html#ga4388f0dd869ef9dbe2da0d2920cca290">More...</a><br /></td></tr>
<tr class="separator:ga4388f0dd869ef9dbe2da0d2920cca290"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ga4513227045ee358f8f2622c8cf0a3485" name="ga4513227045ee358f8f2622c8cf0a3485"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4513227045ee358f8f2622c8cf0a3485">&#9670;&nbsp;</a></span>MTB_KVSTORE_ALIGNMENT_ERROR</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MTB_KVSTORE_ALIGNMENT_ERROR&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 1)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The storage area passed in is not aligned to erase sector boundary. </p>
<p >See notes in <a class="el" href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a> for more information on constraints. </p>

</div>
</div>
<a id="gaa4476b5e7db68726ae74b0153690fbfc" name="gaa4476b5e7db68726ae74b0153690fbfc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa4476b5e7db68726ae74b0153690fbfc">&#9670;&nbsp;</a></span>MTB_KVSTORE_MEM_ALLOC_ERROR</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MTB_KVSTORE_MEM_ALLOC_ERROR&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 2)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Memory allocation failed. </p>
<p >There is not enough space available on the heap. </p>

</div>
</div>
<a id="ga231945421777b158f99b21e5bc2ffde0" name="ga231945421777b158f99b21e5bc2ffde0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga231945421777b158f99b21e5bc2ffde0">&#9670;&nbsp;</a></span>MTB_KVSTORE_INVALID_DATA_ERROR</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MTB_KVSTORE_INVALID_DATA_ERROR&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 3)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Invalid data was detected. </p>
<p >The record may be corrupted. </p>

</div>
</div>
<a id="ga531cd29dc9167444df1474d15a9e263f" name="ga531cd29dc9167444df1474d15a9e263f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga531cd29dc9167444df1474d15a9e263f">&#9670;&nbsp;</a></span>MTB_KVSTORE_ERASED_DATA_ERROR</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MTB_KVSTORE_ERASED_DATA_ERROR&#160;&#160;&#160;    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_KVSTORE, 4)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Erased data was detected. </p>
<p >The record may be corrupted </p>

</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="gacccba62e614b1ebb309dc312b7b67e3a" name="gacccba62e614b1ebb309dc312b7b67e3a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacccba62e614b1ebb309dc312b7b67e3a">&#9670;&nbsp;</a></span>mtb_kvstore_bd_read</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef cy_rslt_t(* mtb_kvstore_bd_read) (void *context, uint32_t addr, uint32_t length, uint8_t *buf)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype for reading data from the block device. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address to read the data from the block device. This address is passed in as start_addr + offset. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">length</td><td>Length of the data that needs to be read. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">buf</td><td>Buffer to read the data. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the read operation. </dd></dl>

</div>
</div>
<a id="gaa832bac0e2f7b15478abb73ae8631b8d" name="gaa832bac0e2f7b15478abb73ae8631b8d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa832bac0e2f7b15478abb73ae8631b8d">&#9670;&nbsp;</a></span>mtb_kvstore_bd_program</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef cy_rslt_t(* mtb_kvstore_bd_program) (void *context, uint32_t addr, uint32_t length, const uint8_t *buf)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype for writing data to the block device. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address to program the data into the block device. This address is passed in as start_addr + offset. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">length</td><td>Length of the data that needs to be written </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">buf</td><td>Data that needs to be written </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the program operation. </dd></dl>

</div>
</div>
<a id="ga8eee071bb3809130b77fb7c8f69e7a67" name="ga8eee071bb3809130b77fb7c8f69e7a67"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8eee071bb3809130b77fb7c8f69e7a67">&#9670;&nbsp;</a></span>mtb_kvstore_bd_erase</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef cy_rslt_t(* mtb_kvstore_bd_erase) (void *context, uint32_t addr, uint32_t length)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype for read from the block device. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address to read the data from the device. This address is passed in as start_addr + offset. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">length</td><td>Length of the data that needs to be erased. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the erase operation. </dd></dl>

</div>
</div>
<a id="ga4d03d5b99d6254298f9eaefb0978170f" name="ga4d03d5b99d6254298f9eaefb0978170f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4d03d5b99d6254298f9eaefb0978170f">&#9670;&nbsp;</a></span>mtb_kvstore_bd_read_size</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef uint32_t(* mtb_kvstore_bd_read_size) (void *context, uint32_t addr)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype to get the read size of the block device for a specific address. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address for which the read size is queried. This address is passed in as start_addr + offset. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Read size of the memory device. </dd></dl>

</div>
</div>
<a id="ga33782352587721d63e4ca26f35558d90" name="ga33782352587721d63e4ca26f35558d90"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga33782352587721d63e4ca26f35558d90">&#9670;&nbsp;</a></span>mtb_kvstore_bd_program_size</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef uint32_t(* mtb_kvstore_bd_program_size) (void *context, uint32_t addr)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype to get the program size of the block device for a specific address. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address for which the program size is queried. This address is passed in as start_addr + offset. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Program size of the memory device. </dd></dl>

</div>
</div>
<a id="ga9dcd451cefcdae7d7063aa2e173b948b" name="ga9dcd451cefcdae7d7063aa2e173b948b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9dcd451cefcdae7d7063aa2e173b948b">&#9670;&nbsp;</a></span>mtb_kvstore_bd_erase_size</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef uint32_t(* mtb_kvstore_bd_erase_size) (void *context, uint32_t addr)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype to get the erase size of the block device for a specific address. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>Context object that is passed into <a class="el" href="group__group__kvstore.html#ga5fa9ddeac64024562e60999088f638b7">mtb_kvstore_init</a> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">addr</td><td>Address for which the erase size is queried. This address is passed in a start_addr + offset. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Erase size of the memory device. </dd></dl>

</div>
</div>
<a id="gaf4640989209ce778da48555edeb7f531" name="gaf4640989209ce778da48555edeb7f531"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf4640989209ce778da48555edeb7f531">&#9670;&nbsp;</a></span>mtb_kvstore_allocate_memory_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void *(* mtb_kvstore_allocate_memory_t) (size_t size)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype for allocating memory to be used for kv-store internal operations. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">size</td><td>Size in bytes of the memory to be allocated </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to the allocated memory in case the memory allocation is success or NULL in case of failure. </dd></dl>

</div>
</div>
<a id="gacc6ed573c4d9f8c441bd4605d26ddd81" name="gacc6ed573c4d9f8c441bd4605d26ddd81"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacc6ed573c4d9f8c441bd4605d26ddd81">&#9670;&nbsp;</a></span>mtb_kvstore_free_memory_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void(* mtb_kvstore_free_memory_t) (void *ptr)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Function prototype for freeing memory. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">ptr</td><td>Pointer to the memory block to be freed </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None. </dd></dl>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga5fa9ddeac64024562e60999088f638b7" name="ga5fa9ddeac64024562e60999088f638b7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5fa9ddeac64024562e60999088f638b7">&#9670;&nbsp;</a></span>mtb_kvstore_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_init </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>start_addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const mtb_block_storage_t *&#160;</td>
          <td class="paramname"><em>bsd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__kvstore.html#gaf4640989209ce778da48555edeb7f531">mtb_kvstore_allocate_memory_t</a>&#160;</td>
          <td class="paramname"><em>alloc_memory</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__kvstore.html#gacc6ed573c4d9f8c441bd4605d26ddd81">mtb_kvstore_free_memory_t</a>&#160;</td>
          <td class="paramname"><em>free_memory</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize an instance of the kv-store library. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">obj</td><td>Pointer to a kv-store object. The caller must allocate the memory for this object but the init function will initialize its contents. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">start_addr</td><td>Start address for the memory. All addresses when performing memory operations will be offset from this address. See notes for constraints. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">length</td><td>Total space available in bytes. See notes for constraints. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">bsd</td><td>Block storage device interface for the underlying memory to be used. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">alloc_memory</td><td>Optional parameter that could be used to allocate the requested memory size. Application could set up this function pointer if they desire to allocate the memory from specific memory region. If not null, KV Store uses the specified function for allocating the memory needed for internal operations. When specified as NULL, KV Store uses the malloc function to allocate the memory </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">free_memory</td><td>Optional parameter that could be used to free the memory block allocated using the 'alloc_memory' function.If not null, KV Store uses the specified function for freeing the memory. When specified as NULL, KV Store uses the free function to free the memory</td></tr>
  </table>
  </dd>
</dl>
<p>Address space considerations </p><dl class="section note"><dt>Note</dt><dd>The start_addr and start_addr + length must be aligned to the erase sector boundary. </dd>
<dd>
An even number of erase sectors must be provided as storage. (2 * N * erase sector size) where N is the number of sectors. </dd>
<dd>
The implementation assumes that the value of the storage in the erased state is either 0x00 or 0xFF. </dd>
<dd>
The space provided to the library provided must have the uniform characteristics (erase, program and read size). A space spanning regions with different characteristics in a hybrid sector device is not supported and if provided may lead to undefined behavior. </dd>
<dd>
If the application desires to use specific memory region for KV Store internal operation, it should set up both the alloc_memory and free_memory functions.</dd></dl>
<p>RTOS considerations </p><dl class="section note"><dt>Note</dt><dd>In a RTOS environment the library must be initialized after the RTOS kernel has started.</dd></dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the initialization operation. </dd></dl>

</div>
</div>
<a id="ga209eef7f4603173449de48d3d4775835" name="ga209eef7f4603173449de48d3d4775835"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga209eef7f4603173449de48d3d4775835">&#9670;&nbsp;</a></span>mtb_kvstore_write()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_write </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Store a key value pair. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key for the data. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>Pointer to the start of the data to be stored. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">size</td><td>Total size of the data in bytes.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the write operation. </dd></dl>

</div>
</div>
<a id="gad2327026f8f741835d012aa0a1f60f14" name="gad2327026f8f741835d012aa0a1f60f14"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad2327026f8f741835d012aa0a1f60f14">&#9670;&nbsp;</a></span>mtb_kvstore_read()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_read </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Read data associated with a key. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key for the data. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">data</td><td>Pointer to the start of the buffer for the data to be read into. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">size</td><td>[in] Total size of the data in bytes. [out] Actual size of the data in storage. If a data buffer is provided then the size cannot be NULL or 0.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>It is valid to set both <code>data</code> and <code>size</code> to NULL to check if the key exists in the storage.</dd></dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the read operation. </dd></dl>

</div>
</div>
<a id="gadd5125b0adf2ef5a4afc39851aeaa288" name="gadd5125b0adf2ef5a4afc39851aeaa288"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadd5125b0adf2ef5a4afc39851aeaa288">&#9670;&nbsp;</a></span>mtb_kvstore_read_partial()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_read_partial </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint32_t&#160;</td>
          <td class="paramname"><em>offset_bytes</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Read data associated with a key. </p>
<p >If buffer is too small, will partially read and fill buffer. No corruption checking is performed.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key for the data. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">data</td><td>Pointer to the start of the buffer for the data to be read into. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">size</td><td>[in] Total size of the data in bytes. [out] Number of bytes read into buffer. If a data buffer is provided then the size cannot be NULL or 0. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">offset_bytes</td><td>Number of bytes to skip at the start the value read into data</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the read operation. </dd></dl>

</div>
</div>
<a id="ga16b0bc2c58f9a4259d295746df43c8ad" name="ga16b0bc2c58f9a4259d295746df43c8ad"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga16b0bc2c58f9a4259d295746df43c8ad">&#9670;&nbsp;</a></span>mtb_kvstore_key_exists()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_key_exists </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Check if a key is stored in memory. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the key_exists operation </dd></dl>

</div>
</div>
<a id="gafd3c856a28b4a326f6e2982f0d18b6dc" name="gafd3c856a28b4a326f6e2982f0d18b6dc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafd3c856a28b4a326f6e2982f0d18b6dc">&#9670;&nbsp;</a></span>mtb_kvstore_value_size()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_value_size </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the size in bytes of data in memory corresponding to a given key. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key for the data </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">size</td><td>Size of data in bytes</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the value size operation </dd></dl>

</div>
</div>
<a id="gafb22467328e29fd0b881eae93679a0f9" name="gafb22467328e29fd0b881eae93679a0f9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafb22467328e29fd0b881eae93679a0f9">&#9670;&nbsp;</a></span>mtb_kvstore_delete()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_delete </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>key</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Delete a key value pair. </p>
<dl class="section note"><dt>Note</dt><dd>This function will return CY_RSLT_SUCCESS if the key cannot be found in the storage.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">key</td><td>Lookup key to delete key value pair.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the delete operation. </dd></dl>

</div>
</div>
<a id="ga543e217c6dad81778e1fc9926e28f23f" name="ga543e217c6dad81778e1fc9926e28f23f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga543e217c6dad81778e1fc9926e28f23f">&#9670;&nbsp;</a></span>mtb_kvstore_size()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t mtb_kvstore_size </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Query the size consumed in the kv-store storage. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Size of storage consumed in bytes. </dd></dl>

</div>
</div>
<a id="ga51591921642d49be5e5c8a9814bebd39" name="ga51591921642d49be5e5c8a9814bebd39"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga51591921642d49be5e5c8a9814bebd39">&#9670;&nbsp;</a></span>mtb_kvstore_remaining_size()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t mtb_kvstore_remaining_size </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Query the free space available in the kv-store storage. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Size of storage free in bytes. </dd></dl>

</div>
</div>
<a id="gad0c50e719da0063d48d9d6224d22c756" name="gad0c50e719da0063d48d9d6224d22c756"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad0c50e719da0063d48d9d6224d22c756">&#9670;&nbsp;</a></span>mtb_kvstore_ensure_capacity()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_ensure_capacity </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Tries to make the specified amount of space available for immediate use. </p>
<p >If necessary, internal cleanup operations will be executed to make additional space available, so this is a potentially long-running operation.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">size</td><td>Amount of space to ensure is available, in bytes. To always perform cleanup operations regardless of the amount of space currently free, use <a class="el" href="group__group__kvstore.html#gab15b7f2a1cea77f4621f72c8082ae352">MTB_KVSTORE_ENSURE_MAX</a>.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the operation. If <code>size</code> is not <a class="el" href="group__group__kvstore.html#gab15b7f2a1cea77f4621f72c8082ae352">MTB_KVSTORE_ENSURE_MAX</a> and it is not possible to make the requested amount of space available, returns <a class="el" href="group__group__kvstore.html#gaf746e26fd8da70e4169614b530371a65">MTB_KVSTORE_STORAGE_FULL_ERROR</a>. </dd></dl>

</div>
</div>
<a id="ga5dc849717a6e3c8b7803fe2224cc6df1" name="ga5dc849717a6e3c8b7803fe2224cc6df1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5dc849717a6e3c8b7803fe2224cc6df1">&#9670;&nbsp;</a></span>mtb_kvstore_reset()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cy_rslt_t mtb_kvstore_reset </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reset kv-store storage. </p>
<p >This function erases all the data in the storage.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the reset operation </dd></dl>

</div>
</div>
<a id="ga4388f0dd869ef9dbe2da0d2920cca290" name="ga4388f0dd869ef9dbe2da0d2920cca290"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4388f0dd869ef9dbe2da0d2920cca290">&#9670;&nbsp;</a></span>mtb_kvstore_deinit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mtb_kvstore_deinit </td>
          <td>(</td>
          <td class="paramtype">mtb_kvstore_t *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Delete kv-store instance. </p>
<p >This function frees any program memory allocated by the library.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a kv-store object </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>(kv-store)</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
